<div class="billing_arcticle_wrapper">
    <div class="billing_arcticle_title">Тикеты</div>
    <div class="billing_arcticle_content">
<?php
if(isset($useridticket)) //открыт полный список, выводим форму для ответа
{
    echo $this->Html->link('К списку тикетов', array('controller' => 'tickets', 'action' => 'index'));
    echo '<br><br>';
    echo '<div class="send_ticket_form_wrapper">';
    echo $this->Form->create('Ticket',array('type' => 'file','action' => 'send_answer'));
    echo $this->Form->input('text', array('label' => false,'required' => 1));
    echo $this->Form->input('orderid', array(
                            'label' => false,
                            'required' => 1,
                            'value' => '0',
                            'div' => array(
				    'class' => 'sendticketorderselect',
				)
                            ));
    echo $this->Form->input('userid', array(
        'label' => false,
        'required' => 1,
        'value' => $useridticket,
        'hidden' => 1
        ));
    echo $this->Form->input('back', array(
        'label' => false,
        'required' => 1,
        'value' => '1',
        'hidden' => 1
        ));
    echo $this->Form->input('file', array(
			    'type' => 'file',
			    'label'=>false,
			    'div' => array(
				'class' => 'attachfilediv',
				)
                            ));
    $options = array(
	'label' => 'Отправить тикет',
	'div' => array(
		'class' => 'sendticketbtn',
		)
	);
    echo $this->Form->end($options);
    echo "</div>";
}
echo '<div class="billing_tickets_list_main_wrp">';
foreach($tickets as $ticket)
{
    $ticket=$ticket['Ticket'];
    $ticket_date=date("H:i d.m.Y",$ticket['time']);
    //echo "Тикет от ";
    if($ticket['back']==0)
    {
        $name=$ticket['login']." (для заказа ID ".$ticket['orderid'].")";
        if(isset($useridticket))
            $name= $this->Html->link($name, array('controller' => 'tickets', 'action' => 'index', $ticket['userid']))." (для заказа ID ".$ticket['orderid'].")";
        else
            $name= $this->Html->link($name, array('controller' => 'tickets', 'action' => 'index', $ticket['userid']));
        echo '<div class="billing_ticket_main_wrp">';
	echo '<div class="billing_ticket_head">'.$ticket_date.'  '.$name.'</div>';
    }
    else
    {
        echo '<div class="billing_ticket_main_wrp_answer">';
	echo '<div class="billing_ticket_head_answer">'.$ticket_date.'  Служба поддержки</div>';
        //echo "Службы поддержки (для заказа ID ".$ticket['orderid'].")";
    }
    echo '<div class="billing_ticket_content">';
    echo '<pre><code>'.$ticket['text'].'</code></pre>';
    if(strlen(@$ticket['file'])>2)
	echo "Вложение: <a href='".@$ticket['file']."'>".@$ticket['file']."</a>";
    echo '</div>'; //close content div
    echo '</div>'; //close wrp div
}
echo $this->Paginator->numbers();
?>
        </div>
    </div>
    <div class="billing_article_links_tickets">
	<?php   echo $this->Paginator->numbers();?>
    </div>
</div>